using System;
using L=Science.Physics.GeneralPhysics;

namespace Serway.Chapter08
{
	/// <summary>
	/// Example05: The Spring-Loaded Popgun
	/// The launching mechanism of a toy gun consists of spring 
	/// of unknown spring constant (Fig.8.9a). When the spring is 
	/// compressed 0.120 m, the gun, when fired vertically, is 
	/// able to launch a 35.0 g projectile to a maximum height 
	/// of 20.0 m above the position of the projectile before firing.
	/// (A) Neglecting all resistive forces, determine the 
	/// spring constant.
	/// k = 953 N/m
	/// (B) Find the speed of the projectile as it moves 
	/// through the equilibrium in Figure 8.9b.
	/// v_b = 19.7 m/s
	/// </summary>
	public class Example05
	{
		public Example05()
		{
		}
		private string result;
		public string Result
		{
			get{return result;}
		}
		public void Compute()
		{
			L.Mass m = new L.Mass();
			m.kg = 0.035;
			L.Length x = new L.Length();
			x.m = 0.12;
			L.Length h = new L.Length();
			h.m = 20.0;
			double k = 2.0*m.kg*
				L.Constant.AccelerationOfGravity*h.m/x.m/x.m;
			result += Convert.ToString(k);
			L.KineticEnergy ke = new L.KineticEnergy();
			ke.J = 0.5*k*x.m*x.m;
			L.Velocity v = new L.Velocity(m,ke);
			result += "\r\n"+Convert.ToString(v.mPERs);
		}			
	}
}
